# -*- coding: utf-8 -*-

'''
Created on Jun 7, 2011

@author: peterd
'''

from django import forms

from mhd.models import MHD_Link, MHD_Link_Direction
from mhd.fields import CharChoiceField
from mhd.widgets import DirectionSelect


class MHD_LinkForm(forms.ModelForm):
    def __init__(self, *args, **kwargs): 
        super(MHD_LinkForm, self).__init__(*args, **kwargs)
        if kwargs and kwargs.has_key('instance'):
            self.fields['direction'].queryset = MHD_Link_Direction.objects.filter(link__name = kwargs['instance'].name)            
 
            
    class Meta:
        model = MHD_Link
        fields = ('name',)

    direction = CharChoiceField(label = u'Smer', queryset = None, empty_label = None, widget = DirectionSelect) 
    stop_filter = forms.ChoiceField(label = u'Zobraz zástavky', choices = (('all', u'Všetky'), ('noloc', u'Iba nezamerané')))

    


    
